<!--
 * @Description: 
 * @Author: dh
 * @Date: 2021-09-16 17:54:02
 * @LastEditors: dh
 * @LastEditTime: 2021-09-27 15:59:09
-->
<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>web worker</title>
	</head>

	<body>
		<script>
			const myWorker = new SharedWorker('SharedWorker.js');

			myWorker.port.postMessage('share2');

			// 直接给port绑定事件函数，不需要start方法
			myWorker.port.onmessage = function (e) {
				console.log(e);
			};
		</script>
	</body>
</html>
